//
//  TTStatusBarSaver.m
//  Tint
//
//  Created by Kevin Wu on 2/27/12.
//  Copyright (c) 2012 Telligenty. All rights reserved.
//

#import "TTStatusBarSaver.h"

@implementation TTStatusBarSaver

TTSynthesizeSingleton(TTStatusBarSaver);


#pragma mark - Public

- (void)pushStatusBar {
    TTStatusBarSaverItem *item = [TTStatusBarSaverItem make];
    item.statusBarHidden = [UIApplication sharedApplication].statusBarHidden;
    item.statusBarStyle = [UIApplication sharedApplication].statusBarStyle;
    [_appearances push:item];
}

- (void)popStatusBar {
    [self popStatusBarWithBarAnimation:UIStatusBarAnimationNone animated:NO];
}

- (void)popStatusBarWithBarAnimation:(UIStatusBarAnimation)barAnimation animated:(BOOL)animated {
    TTStatusBarSaverItem *item = [_appearances pop];
    if (item) {
        [[UIApplication sharedApplication] setStatusBarHidden:item.statusBarHidden withAnimation:barAnimation];
        [[UIApplication sharedApplication] setStatusBarStyle:item.statusBarStyle animated:animated];
    }
}

@end


@implementation TTStatusBarSaverItem
@synthesize statusBarHidden = _statusBarHidden;
@synthesize statusBarStyle = _statusBarStyle;
@end
